How to display strings in activity 3 from activity 1, 2? [migrated]

Posted by user107160 on Programmers See other posts from Programmers or by user107160
Published on 2013-11-07T19:01:31Z Indexed on 2013/11/07 22:19 UTC
Read the original article Hit count: 180

Filed under:
|

I need to get strings values from two different activities say activity1 and activity2, each activity should have maximum 4 edittext field..so totally eight fields should be displayed orderly in activity3. I have tried the code which is not displaying in the activity3.

Look at code,

Activity1

String namef = fname.getText().toString();
Intent first = new Intent(AssessmentActivity.this, Second.class);
first.putExtra("list1", namef);
startActivity(first);

String namel = lname.getText().toString();
Intent second = new Intent(AssessmentActivity.this, Second.class);
second.putExtra("list2", namel);
startActivity(second);

String phone = mob.getText().toString();
Intent third = new Intent(AssessmentActivity.this, Second.class);
third.putExtra("list3", phone);
startActivity(third);   

String mailid = email.getText().toString();
Intent fourth = new Intent(AssessmentActivity.this, Second.class);
fourth.putExtra("list4", mailid);
startActivity(fourth);

Activity2

String cont = addr.getText().toString();
Intent fifth = new Intent(Second.this, Third.class);
fifth.putExtra("list5", cont);
startActivity(fifth);

String db = dob.getText().toString();
Intent sixth = new Intent(Second.this, Third.class);
sixth.putExtra("list6", db);
startActivity(sixth);

String nation = citizen.getText().toString();
Intent Seventh = new Intent(Second.this, Third.class);
Seventh.putExtra("list7", nation);
startActivity(Seventh);

String subject = course.getText().toString();
Intent Eight = new Intent(Second.this, Third.class);
Eight.putExtra("list8", subject);
startActivity(Eight);

*Activity3*

TextView first = (TextView)findViewById(R.id.textView2);
String fieldone = getIntent().getStringExtra("list1" );
first.setText(fieldone);

TextView second = (TextView)findViewById(R.id.textView3);
String fieldtwo = getIntent().getStringExtra("list2" );
second.setText(fieldtwo);

TextView third = (TextView)findViewById(R.id.textView4);
String fieldthree = getIntent().getStringExtra("list3" );
third.setText(fieldthree);

TextView fourth = (TextView)findViewById(R.id.textView5);
String fieldfour = getIntent().getStringExtra("list4" );
fourth.setText(fieldfour);

TextView fifth = (TextView)findViewById(R.id.textView6);
String fieldfive = getIntent().getStringExtra("list5" );
fifth.setText(fieldfive);

TextView sixth = (TextView)findViewById(R.id.textView7);
String fieldsix = getIntent().getStringExtra("list6" );
sixth.setText(fieldsix);

TextView seventh = (TextView)findViewById(R.id.textView8);
String fieldseven = getIntent().getStringExtra("list7" );
seventh.setText(fieldseven);

TextView eight = (TextView)findViewById(R.id.textView3);
String fieldeight = getIntent().getStringExtra("list8");
eight.setText(fieldeight);

© Programmers or respective owner

Related posts about android

Related posts about Developer